<template>
  <div>
    <el-container>
      <el-main class="el-main">
        <articleScrollPage/>
      </el-main>
      <el-aside>
<!--        <PersonalInfoCard></PersonalInfoCard>-->
        <ArticleCard card-header="热门文章" :articles="hotArticles"></ArticleCard>
        <ArticleCard card-header="最新文章" :articles="newArticles"></ArticleCard>
      </el-aside>
    </el-container>
  </div>
</template>

<script>

import articleScrollPage from "@/components/articleScrollPage";
import PersonalInfoCard from "@/pages/personalInfoCard";
import ArticleCard from "@/pages/AtricleCard";
import {getHotArticles,getNewArticles} from "@/api/article"

export default {
  name: "index",
  data(){
    return {
      hotArticles:[],
      newArticles:[]
    }
  },
  components: {
    PersonalInfoCard,
    articleScrollPage,
    ArticleCard,
  },
  methods:{
    getHotArticles(){
      getHotArticles().then((res)=>{
        if(res.data.data){
          this.hotArticles = res.data.data;
        }else {
          this.$message("系统错误")
        }
      }).catch((err)=>{
        this.$message("系统错误")
      })
    },
    getNewArticles(){
      getNewArticles().then((res)=>{
        if(res.data.data){
          this.newArticles = res.data.data;
        }else {
          this.$message("系统错误")
        }
      }).catch((err)=>{
        this.$message("系统错误")
      })
    }

  },
  created() {
    this.getNewArticles()
    this.getHotArticles()
  }
}
</script>

<style scoped>
  .el-container {
    width: 1360px;
  }

  .el-aside {
    width: 120px;
  }

  .el-main {
    padding: 0px;
    line-height: 16px;
  }

  /*.el-card {
    border-radius: 50px;
  }*/

  .el-card:not(:first-child) {
    margin-top: 20px;
  }

</style>
